package npap.cater.unr.edu.client.scaffold;

import npap.cater.unr.edu.client.managed.ui.ApplicationListPlaceRenderer;
import npap.cater.unr.edu.client.proxy.ProjectProxy;
import npap.cater.unr.edu.client.scaffold.place.ProxyListPlace;
import npap.cater.unr.edu.client.scaffold.place.customized.CustomizedApplicationListPlaceRenderer;
import npap.cater.unr.edu.client.scaffold.place.customized.ProjectListPlace;
import npap.cater.unr.edu.client.scaffold.place.customized.ProjectListPlaceRender;
import npap.cater.unr.edu.client.scaffold.ui.LoginWidget;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*;

/**
 * The outermost UI of the application.
 */
public class ScaffoldDesktopShell extends Composite {
	
	interface Binder extends UiBinder<Widget, ScaffoldDesktopShell> {
	}

	private static final Binder BINDER = GWT.create(Binder.class);

	/**
	 * @uml.property  name="details"
	 * @uml.associationEnd  readOnly="true"
	 */
	@UiField SimplePanel details;
	/**
	 * @uml.property  name="error"
	 * @uml.associationEnd  readOnly="true"
	 */
	@UiField DivElement error;
	/**
	 * @uml.property  name="loginWidget"
	 * @uml.associationEnd  readOnly="true"
	 */
	@UiField LoginWidget loginWidget;
	/**
	 * @uml.property  name="master"
	 * @uml.associationEnd  readOnly="true"
	 */
	@UiField SimplePanel master;
	/**
	 * @uml.property  name="projectList"
	 * @uml.associationEnd  readOnly="true"
	 */
	@UiField SimplePanel projectList;
	
	@UiField
    Button createNewProject;
	/**
	 * @return
	 * @uml.property  name="projectList"
	 */
	public SimplePanel getProjectList() {
		return projectList;
	}

	/**
	 * @uml.property  name="mole"
	 * @uml.associationEnd  readOnly="true"
	 */
	@UiField NotificationMole mole;
	/**
	 * @uml.property  name="placesBox"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	@UiField(provided = true)
	ValuePicker<ProxyListPlace> placesBox = new ValuePicker<ProxyListPlace>(new CustomizedApplicationListPlaceRenderer());
	/**
	 * @uml.property  name="projectPlacesBox"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	@UiField(provided = true)
	ValuePicker<ProjectListPlace> projectPlacesBox = new ValuePicker<ProjectListPlace>(new ProjectListPlaceRender());
	
	@UiHandler("createNewProject")
    void handleClick(ClickEvent e) {
       Window.alert("Hello, AJAX");
     }
	
	public ValuePicker<ProjectListPlace> getProjectPlacesBox() {
		return projectPlacesBox;
	}

	public ScaffoldDesktopShell() {
		initWidget(BINDER.createAndBindUi(this));
		createNewProject.setEnabled(true);

	}

	/**
	 * @return the panel to hold the details
	 */
	public SimplePanel getDetailsPanel() {
		return details;
	}

	/**
	 * @return  the login widget
	 * @uml.property  name="loginWidget"
	 */
	public LoginWidget getLoginWidget() {
		return loginWidget;
	}

	/**
	 * @return the panel to hold the master list
	 */
	public SimplePanel getMasterPanel() {
		return master;
	}

	/**
	 * @return  the notification mole for loading feedback
	 * @uml.property  name="mole"
	 */
	public NotificationMole getMole() {
		return mole;
	}

	/**
	 * @return the navigator
	 */
	public HasConstrainedValue<ProxyListPlace> getPlacesBox() {
		return placesBox;
	}
	
	

	/**
	 * @param string
	 */
	public void setError(String string) {
		error.setInnerText(string);
	}
	
	 
}
